package com.fxu.role.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fxu.framework.core.base.Cascade;
import com.fxu.framework.core.sql.SEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import static com.baomidou.mybatisplus.annotation.FieldFill.UPDATE;

/***
 * <p>fxu</p>
 * 地区表：[region]的数据实体类
 * @author fangxu
 * @version  2021-04-11
 ***/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "Region", description = "地区")
@TableName("fxu_region")
public class Region extends SEntity<Region> implements Serializable {
/*=== 自动生成代码 开始 ===*/
    private static final long serialVersionUID = 3353541952745849985L;

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "自增ID[支持普通搜索]")
    private Long id;

    @ApiModelProperty(value = "名称[支持普通搜索]", required = true)
    private String name;

    @ApiModelProperty(value = "上级ID[支持普通搜索]", required = true)
    private Integer parentId;

    @ApiModelProperty(value = "级别", required = true)
    private Integer level;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @TableField(fill = UPDATE, update = "%s+1")
    @ApiModelProperty(value = "版本号")
    private Integer version;

    @TableField(exist = false)
    @ApiModelProperty(value = "子列表")
    @Cascade(thisField = "id", linkField = "parentId")
    private List<Region> childList;
/*=== 自动生成代码 结束 ===*/
}
